package com.yjc.blog.controller;


import com.yjc.blog.domain.bo.DocDao;
import com.yjc.blog.domain.bo.DocSave;
import com.yjc.blog.domain.vo.DocVO;
import com.yjc.blog.domain.vo.PageVO;
import com.yjc.blog.service.IDocService;
import com.yjc.blog.utils.R;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 文档 前端控制器
 * </p>
 *
 * @author yjc
 * @since 2024-11-01
 */
@RestController
@RequestMapping("/doc")
public class DocController {
    @Resource
    private IDocService docService;

    @GetMapping("/list")
    public R<PageVO<DocVO>> list(@Valid DocDao dao){
        PageVO<DocVO> list = docService.docList(dao);
        R<PageVO<DocVO>> r = new R<>();
        r.setContent(list);
        return r;
    }
    @PostMapping("/save")
    public R<Object> save(@RequestBody DocSave save){
        docService.docSave(save);
        return new R<>();
    }
    @DeleteMapping("/delete/{ids}")

    public R delete(@PathVariable("ids") String ids){
        docService.delete(ids);
        return new R<>();
    }
}
